package com.practice.selenium.test;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import com.practice.selenium.driver.WebDriverFactory;

public class SearchTextTestCase implements TestCase {

	private static final String HOME_URL = "http://cn.bing.com/";
	private static final String SEARCH_BUTTON_XPATH = "//*[@id=\"sb_form_go\"]";
	private static final String SEARCH_INPUT_XPATH = "//*[@id=\"sb_form_q\"]";
	
	private static final String SEARCH_TEXT = "My Search";
	
	@Override
	public void test() {
		WebDriver driver = WebDriverFactory.getInstance().createWebDriver();
		driver.get(HOME_URL);

		System.out.println(driver.getTitle());

		WebElement inputTextbox = driver.findElement(By.xpath(SEARCH_INPUT_XPATH));
		inputTextbox.sendKeys(SEARCH_TEXT);

		WebElement searchButton = driver.findElement(By.xpath(SEARCH_BUTTON_XPATH));
		searchButton.click();

		driver.quit();
	}
	
}
